//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2022 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if compiler(>=5.5.2) && canImport(_Concurrency)

import SotoCore

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension BackupStorage {
    // MARK: Async API Calls

    /// Delete Object from the incremental base Backup.
    public func deleteObject(_ input: DeleteObjectInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws {
        return try await self.client.execute(operation: "DeleteObject", path: "/backup-jobs/{BackupJobId}/object/{ObjectName}", httpMethod: .DELETE, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Gets the specified object's chunk.
    public func getChunk(_ input: GetChunkInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> GetChunkOutput {
        return try await self.client.execute(operation: "GetChunk", path: "/restore-jobs/{StorageJobId}/chunk/{ChunkToken}", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Get metadata associated with an Object.
    public func getObjectMetadata(_ input: GetObjectMetadataInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> GetObjectMetadataOutput {
        return try await self.client.execute(operation: "GetObjectMetadata", path: "/restore-jobs/{StorageJobId}/object/{ObjectToken}/metadata", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// List chunks in a given Object
    public func listChunks(_ input: ListChunksInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> ListChunksOutput {
        return try await self.client.execute(operation: "ListChunks", path: "/restore-jobs/{StorageJobId}/chunks/{ObjectToken}/list", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// List all Objects in a given Backup.
    public func listObjects(_ input: ListObjectsInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> ListObjectsOutput {
        return try await self.client.execute(operation: "ListObjects", path: "/restore-jobs/{StorageJobId}/objects/list", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Complete upload
    public func notifyObjectComplete(_ input: NotifyObjectCompleteInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> NotifyObjectCompleteOutput {
        return try await self.client.execute(operation: "NotifyObjectComplete", path: "/backup-jobs/{BackupJobId}/object/{UploadId}/complete", httpMethod: .PUT, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Upload chunk.
    public func putChunk(_ input: PutChunkInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> PutChunkOutput {
        return try await self.client.execute(operation: "PutChunk", path: "/backup-jobs/{BackupJobId}/chunk/{UploadId}/{ChunkIndex}", httpMethod: .PUT, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Upload object that can store object metadata String and data blob in single API call using inline chunk field.
    public func putObject(_ input: PutObjectInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> PutObjectOutput {
        return try await self.client.execute(operation: "PutObject", path: "/backup-jobs/{BackupJobId}/object/{ObjectName}/put-object", httpMethod: .PUT, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Start upload containing one or many chunks.
    public func startObject(_ input: StartObjectInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> StartObjectOutput {
        return try await self.client.execute(operation: "StartObject", path: "/backup-jobs/{BackupJobId}/object/{ObjectName}", httpMethod: .PUT, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    // MARK: Streaming Async API Calls

    /// Gets the specified object's chunk.
    public func getChunkStreaming(_ input: GetChunkInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil, _ stream: @escaping (ByteBuffer, EventLoop) -> EventLoopFuture<Void>) async throws -> GetChunkOutput {
        return try await self.client.execute(operation: "GetChunk", path: "/restore-jobs/{StorageJobId}/chunk/{ChunkToken}", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop, stream: stream)
    }

    /// Get metadata associated with an Object.
    public func getObjectMetadataStreaming(_ input: GetObjectMetadataInput, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil, _ stream: @escaping (ByteBuffer, EventLoop) -> EventLoopFuture<Void>) async throws -> GetObjectMetadataOutput {
        return try await self.client.execute(operation: "GetObjectMetadata", path: "/restore-jobs/{StorageJobId}/object/{ObjectToken}/metadata", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop, stream: stream)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension BackupStorage {
    ///  List chunks in a given Object
    /// Return PaginatorSequence for operation.
    ///
    /// - Parameters:
    ///   - input: Input for request
    ///   - logger: Logger used flot logging
    ///   - eventLoop: EventLoop to run this process on
    public func listChunksPaginator(
        _ input: ListChunksInput,
        logger: Logger = AWSClient.loggingDisabled,
        on eventLoop: EventLoop? = nil
    ) -> AWSClient.PaginatorSequence<ListChunksInput, ListChunksOutput> {
        return .init(
            input: input,
            command: self.listChunks,
            inputKey: \ListChunksInput.nextToken,
            outputKey: \ListChunksOutput.nextToken,
            logger: logger,
            on: eventLoop
        )
    }

    ///  List all Objects in a given Backup.
    /// Return PaginatorSequence for operation.
    ///
    /// - Parameters:
    ///   - input: Input for request
    ///   - logger: Logger used flot logging
    ///   - eventLoop: EventLoop to run this process on
    public func listObjectsPaginator(
        _ input: ListObjectsInput,
        logger: Logger = AWSClient.loggingDisabled,
        on eventLoop: EventLoop? = nil
    ) -> AWSClient.PaginatorSequence<ListObjectsInput, ListObjectsOutput> {
        return .init(
            input: input,
            command: self.listObjects,
            inputKey: \ListObjectsInput.nextToken,
            outputKey: \ListObjectsOutput.nextToken,
            logger: logger,
            on: eventLoop
        )
    }
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)
